﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SyncList.Business.ValueObject
{
    /// <summary>
    /// Définition d'un fichier
    /// </summary>
    public class FileDef : FileDefBase
    {

        private string _name;
        //private long _size;
        private string _localFolder;
        //private string _hash;


        /// <summary>
        /// Nom du fichier
        /// </summary>
        public string Name
        {
            get { return (_name); }
            set { this._name = value; }
        }


        ///// <summary>
        ///// Taille du fichier
        ///// </summary>
        //public long Size
        //{
        //    get { return(_size); }
        //    set { this._size = value; }
        //}


        ///// <summary>
        ///// Hash du fichier
        ///// </summary>
        //public string Hash
        //{
        //    get { return (_hash); }
        //    set { this._hash = value; }
        //}


        /// <summary>
        /// Chemin sur le PC local
        /// </summary>
        public string LocalFolder
        {
            get { return (_localFolder); }
            set { _localFolder = value; }
        }


        /// <summary>
        /// Nom court
        /// </summary>
        public string ShortName
        {
            get
            {
                string txt = "";
                int maxLength = 39;
                if (_name.Length > maxLength)
                    txt = _name.Substring(0, maxLength - 3) + "...";
                else
                    txt = _name;
                return (txt);
            }
        }


        /// <summary>
        /// Afficher le tooltip
        /// </summary>
        public string ToolTip
        {
            get { return (Name + " (" + FormattedSize + ")"); }
        }


        /// <summary>
        /// Extension du fichier
        /// </summary>
        public string Extension
        {
            get
            {
                string extension = "";
                int extPos = _name.LastIndexOf('.');
                if (extPos >= 0)
                    extension = _name.Substring(extPos);                   
                return (extension);
            }
        }


    }
}
